package javacafe.serviceimple;

import java.util.HashMap;
import java.util.Map;

import javacafe.dao.MemberDAO;
import javacafe.dao.StudyMemberDAO;
import javacafe.daoimpl.MemberDAOImple;
import javacafe.daoimpl.StudyMemberDAOImpl;
import javacafe.dto.study.StudyAuthDTO;
import javacafe.dto.study.StudyMemberDTO;
import javacafe.service.StudyMemberService;

public class StudyMemberServiceImpl implements StudyMemberService {
	
	private StudyMemberDAO studyMemberDAO;
	private static StudyMemberServiceImpl studyMemberService;
	
	private StudyMemberServiceImpl() {		
		studyMemberDAO = new StudyMemberDAOImpl();
	}
	
	public static StudyMemberServiceImpl getInstance(){
		if (studyMemberService==null) {
			studyMemberService=new StudyMemberServiceImpl();
		}
		return studyMemberService;
	}
	
	@Override
	public void addMember(StudyMemberDTO dto) {
		studyMemberDAO.insertMember(dto);
	}

	@Override
	public StudyMemberDTO getStudyMember(int studyNo, int mNo) {
		Map<String, Integer> map = new HashMap<String, Integer>();
		map.put("study_no", studyNo);
		map.put("m_no", mNo);
		return studyMemberDAO.getStudyMember(map);
	}

	@Override
	public void addStudyAuth(StudyAuthDTO studyAuth) {
		studyMemberDAO.addStudyAuth(studyAuth);
	}

}
